📄 multipagewizard.java
字号:
// Decompiled by Jad v1.5.8e2. Copyright 2001 Pavel Kouznetsov.
// Jad home page: http://kpdus.tripod.com/jad.html
// Decompiler options: packimports(3) fieldsfirst ansi space
// Source File Name: MultipageWizard.java
package org.gudy.azureus2.ui.swt.shells;
import java.util.*;
import org.eclipse.swt.custom.StackLayout;
import org.eclipse.swt.graphics.Image;
import org.eclipse.swt.graphics.Point;
import org.eclipse.swt.layout.GridData;
import org.eclipse.swt.layout.GridLayout;
import org.eclipse.swt.widgets.*;
import org.gudy.azureus2.core3.util.Debug;
import org.gudy.azureus2.ui.swt.Utils;
import org.gudy.azureus2.ui.swt.components.shell.ShellFactory;
// Referenced classes of package org.gudy.azureus2.ui.swt.shells:
// IWizardPage
public abstract class MultipageWizard
{
private Shell shell;
private Display display;
private int shellStyle;
private Shell parent;
private Composite topPanel;
private Composite contentPanel;
private Label titleLabel;
private Label descriptionLabel;
private Map pages;
private StackLayout contentStackLayout;
private IWizardPage currentPage;
private IWizardPage previousPage;
private List initializedPages;
public MultipageWizard(Display display, int shellStyle)
{
pages = new LinkedHashMap();
initializedPages = new ArrayList();
this.display = display;
this.shellStyle = shellStyle;
init();
}
public MultipageWizard(Shell parent, int shellStyle)
{
pages = new LinkedHashMap();
initializedPages = new ArrayList();
this.parent = parent;
this.shellStyle = shellStyle;
init();
}
public abstract void createPages();
private void init()
{
if (null != parent)
shell = ShellFactory.createShell(parent, shellStyle);
else
shell = ShellFactory.createShell(display, shellStyle);
createControls();
createPages();
}
private void createControls()
{
GridLayout gLayout = new GridLayout();
gLayout.marginHeight = 0;
gLayout.marginWidth = 0;
gLayout.verticalSpacing = 0;
shell.setLayout(gLayout);
Utils.setShellIcon(shell);
topPanel = new Composite(shell, 0);
topPanel.setLayoutData(new GridData(4, 128, true, false));
GridLayout gLayout1 = new GridLayout();
gLayout1.marginBottom = 10;
topPanel.setLayout(gLayout1);
topPanel.setBackground(shell.getDisplay().getSystemColor(25));
topPanel.setBackgroundMode(2);
Label separator1 = new Label(shell, 258);
separator1.setLayoutData(new GridData(4, 0x1000000, true, false));
contentPanel = new Composite(shell, 0);
contentPanel.setLayoutData(new GridData(4, 4, true, true));
contentStackLayout = new StackLayout();
contentPanel.setLayout(contentStackLayout);
titleLabel = new Label(topPanel, 0);
titleLabel.setLayoutData(new GridData(4, 128, true, false));
Utils.setFontHeight(titleLabel, 16, 0);
descriptionLabel = new Label(topPanel, 64);
GridData gData = new GridData(4, 4, true, true);
gData.horizontalIndent = 10;
descriptionLabel.setLayoutData(gData);
shell.layout(true, true);
}
public void fullScreen(boolean isFullScreen)
{
topPanel.setVisible(!isFullScreen);
((GridData)topPanel.getLayoutData()).exclude = isFullScreen;
shell.layout(true, true);
}
public boolean addPage(IWizardPage page)
{
if (null == page)
return false;
if (pages.containsKey(page.getPageID()))
{
Debug.out((new StringBuilder()).append("MultipageWizard:: a page with this ID already exists ID:").append(page.getPageID()).toString());
return false;
}
pages.put(page.getPageID(), page);
if (page.isInitOnStartup())
{
page.createControls(contentPanel);
initializedPages.add(page.getPageID());
}
return true;
}
public boolean isFirstPage(String pageID)
{
if (!pages.isEmpty())
return pageID.equals(((IWizardPage)pages.values().iterator().next()).getPageID());
else
return false;
}
public boolean isLastPage(String pageID)
{
if (!pages.isEmpty())
{
IWizardPage page = null;
for (Iterator iterator = pages.values().iterator(); iterator.hasNext();)
page = (IWizardPage)iterator.next();
if (null != page)
return page.getPageID().equals(pageID);
}
return false;
}
public boolean removePage(IWizardPage page)
{
if (null == page)
return false;
if (!pages.containsKey(page.getPageID()))
{
Debug.out((new StringBuilder()).append("MultipageWizard:: a page with this ID is not found ID:").append(page.getPageID()).toString());
return false;
} else
{
pages.remove(page.getPageID());
page.performDispose();
return true;
}
}
public void showPage(String pageID)
{
if (!pages.containsKey(pageID))
{
Debug.out((new StringBuilder()).append("MultipageWizard:: a page with this ID is not found ID:").append(pageID).toString());
return;
}
IWizardPage page = (IWizardPage)pages.get(pageID);
if (null != currentPage)
{
if (currentPage.getPageID().equals(page.getPageID()))
return;
currentPage.performAboutToBeHidden();
}
if (!initializedPages.contains(page.getPageID()))
{
page.createControls(contentPanel);
initializedPages.add(page.getPageID());
}
page.performAboutToBeShown();
previousPage = currentPage;
currentPage = page;
contentStackLayout.topControl = page.getControl();
update();
contentPanel.layout(true);
}
public void open()
{
if (!pages.isEmpty())
{
IWizardPage page = (IWizardPage)pages.values().iterator().next();
showPage(page.getPageID());
}
shell.open();
}
private void update()
{
if (null != currentPage)
{
setText(currentPage.getWindowTitle());
setTitle(currentPage.getTitle());
setDescription(currentPage.getDesciption());
}
}
public void setTitle(String title)
{
titleLabel.setText((new StringBuilder()).append(title).append("").toString());
}
public void setDescription(String description)
{
descriptionLabel.setText((new StringBuilder()).append(description).append("").toString());
}
public IWizardPage getPage(String pageID)
{
if (!pages.containsKey(pageID))
{
Debug.out((new StringBuilder()).append("MultipageWizard:: a Page with this ID is not found ID:").append(pageID).toString());
return null;
} else
{
return (IWizardPage)pages.get(pageID);
}
}
public void performCancel()
{
close();
}
public void performNext()
{
if (pages.isEmpty())
return;
if (null == currentPage)
{
IWizardPage page = (IWizardPage)pages.values().iterator().next();
showPage(page.getPageID());
} else
{
boolean foundCurrent = false;
Iterator iterator = pages.values().iterator();
do
{
if (!iterator.hasNext())
break;
IWizardPage page = (IWizardPage)iterator.next();
if (foundCurrent)
{
showPage(page.getPageID());
return;
}
if (page.getPageID().equals(currentPage.getPageID()))
foundCurrent = true;
} while (true);
if (!foundCurrent)
Debug.out("MultipageWizard:: there is no more page to go to");
}
}
public void performBack()
{
if (null != previousPage)
showPage(previousPage.getPageID());
}
public Shell getShell()
{
return shell;
}
public void close()
{
shell.close();
}
public Object getData(String key)
{
return shell.getData(key);
}
public Point getLocation()
{
return shell.getLocation();
}
public Point getSize()
{
return shell.getSize();
}
public String getText()
{
return shell.getText();
}
public String getToolTipText()
{
return shell.getToolTipText();
}
public void setBounds(int x, int y, int width, int height)
{
shell.setBounds(x, y, width, height);
}
public void setData(String key, Object value)
{
shell.setData(key, value);
}
public void setLocation(int x, int y)
{
shell.setLocation(x, y);
}
public void setSize(int width, int height)
{
shell.setSize(width, height);
}
public void setText(String string)
{
shell.setText(string);
}
public void setToolTipText(String string)
{
shell.setToolTipText(string);
}
public void setVisible(boolean visible)
{
shell.setVisible(visible);
}
public Image getImage()
{
return shell.getImage();
}
public void setImage(Image image)
{
shell.setImage(image);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -